package main

// 字符串：拼接

import (
	"fmt"
	"strings"
)

func stringsBuilderDemo() {
	var builder strings.Builder
	builder.WriteString("Hello")
	builder.WriteString(" ")
	builder.WriteString("World")
	builder.WriteString("!")
	str := builder.String()

	fmt.Println(str)
}

func stringsJoinDemo() {
	parts := []string{"Apple", "Baidu", "!"}
	str1 := strings.Join(parts, " ")

	fmt.Println(str1)
}

func stringsAppendDemo() {

	parts := make([]byte, 0, 32)
	parts = append(parts, "hello"...)
	parts = append(parts, " "...)
	parts = append(parts, "world"...)
	parts = append(parts, "~"...)
	str := string(parts)
	fmt.Println(str)
}

func main() {
	stringsBuilderDemo()

	stringsJoinDemo()

	stringsAppendDemo()
}
